package cz.muni.fi.pv112.cranesimulator.utils.handlers.opengl;

import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureData;
import java.io.IOException;
import javax.media.opengl.GL;
import static com.jogamp.opengl.util.texture.TextureIO.newTextureData;

/**
 *
 * @author Michal Ďuriš
 */
public class TextureHandler {

    public static Texture loadTexture(GL gl, String path,
                                      boolean mipmapGenEnabled,
                                      String fileSuffix) throws IOException {
        TextureData textureData = newTextureData(gl.getGLProfile(),
                TextureHandler.class
                .getResource(path),
                mipmapGenEnabled, fileSuffix);

        return new Texture(gl, textureData);
    }

    public static Texture[] loadTextures(GL gl, String[] paths,
                                         boolean mipmapGenEnabled,
                                         String fileSuffix) throws IOException {
        Texture[] textures = new Texture[paths.length];

        for (int i = 0; i < textures.length; i++) {
            textures[i] = loadTexture(gl, paths[i], mipmapGenEnabled, fileSuffix);
        }

        return textures;
    }

}
